/**
 *  学习目标：useEffect监听多个状态-接收多个依赖项
 */
import React, { useEffect, useState } from 'react';

export default function App() {
    const [count, setCount] = useState(0);
    const [msg, setMsg] = useState('Hello React');

    useEffect(() => {
        console.log('count + msg----->  ', count + msg);
    }, [count, msg]);//依赖项可以有多个，表示任意依赖项变化都能触发
    // 不过不推荐，所有依赖项都写在同一个里面

    return (
        <div>
            count -- {count}
            msg -- {msg}
            <button onClick={() => setCount(count + 1)}>点我修改title</button>
            <button onClick={() => setMsg(msg + '~')}>点我修改Msg</button>
        </div>
    );
}
